Ext.define('UDZ.view.CartList', {
    extend: 'Ext.dataview.component.DataItem',
    xtype: 'CartList',
    requires: [
        // 'Ext.Button',
        // 'Ext.field.Spinner',
        // 'Ext.Img',
    ],
    config:{
        xtype:'panel',
        cls:'border',
        style:'position:relative;min-height:150px;padding:15px 0',
        layout: {
            type:'hbox'
        },
        // defaults:{
        //   padding:'15px '
        // },
        items:[
            {
                // width:'40px',
                flex:1,
                xtype: 'checkboxfield',
                cls:'checkbox',
                html:[
                    '<span></span>'
                ]
            },
            {
                flex:2,
                xtype: 'image',
                itemId: 'cart_goods_view_img',
                // src: config.website+'/assets/img/nopic3.png',
                src:'resources/images/30.jpg',
                height: 100,
                // width:'80px',
                style: {
                    'background-size': '70px',
                    'margin': '10px',
                }
            },
            {
                // width:'205px',
                flex:5,
                xtype:'panel',
               layout:{
                    type:'vbox',
               },
                // defaults:{
                //   padding:'5px '
                // },
                items:[
                    {
                        flex:1,
                        xtype: 'component',
                        itemId: 'cart_goods_view_name',
                        cls: 'cart_goods_view_name',
                        html: '商品名称',
                        padding: '10px 0 0 5px'
                    },
                    {
                        flex:1,
                        xtype: 'panel',
                        itemId: 'cart_goods_view_size',
                        cls:'cart_goods_view_size',
                        html: [
                            '<span style="font-size: 0.8em;">XL/160</span> <span>黑色</span>'
                        ],
                        padding: '5px 0 0px 5px'
                    },
                    {
                        xtype: 'spinnerfield',
                        itemId: 'cart_goods_view_spinner',
                        flex:1,
                        width:'60%',
                        minValue: 1,
                        stepValue: 1,
                        groupButtons: false,
                        // padding: '13px 20px 13px 10px'
                    },
                ]
            },
           {
                // width:'69px',
               flex:3,
                xtype: 'panel',
                items:[
                   {
                       flex: 1,
                       itemId:'cart_goods_view_price',
                       cls:'cart_goods_view_price',

                   },
                    {
                        flex:1,
                        xtype: 'button',
                        text: '删除',
                        width:'70%',
                        margin: '50px 0 0 10px'
                    }
               ]
           }
        ]
    },
    updateRecord: function(record){
        var me =this;
        if(record.get('directory') && (record.get('logo') != "" || record.get('logo') != "noMatch")){
            // var img = config.upload+"s/"+record.get('directory')+'/'+record.get('logo');
            me.down('#cart_goods_view_img').setSrc(img);
        }
        me.down('#cart_goods_view_name').setHtml("<span style='font-size: 0.8em'>"+(record.get('name').length < 10 ? record.get('name') : record.get('name').substr(0,20)+"...")+"</span>");
        me.down('#cart_goods_view_price').setHtml("<span style='font-size:1em;font-weight: 600;padding: 5px'>￥"+record.get('price')+"</span>");
        me.down('#cart_goods_view_spinner').setValue(record.get('qty'));
        me.down('#cart_goods_view_spinner').setMaxValue(record.get('stock'));
        this.callParent(arguments);
    }
});


